import book.Book;
import book.BookList;
import user.AdminUser;
import user.NormalUser;
import user.User;

import java.util.Scanner;

public class Test {
    public static void main(String[] args) {
        System.out.println("************欢迎翻阅书架***********");
        System.out.println("************你的姓名是:************");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();
        System.out.println("是否是管理员：1.是  0.不是");
        int choice = scanner.nextInt();
        BookList books = new BookList(10); //放10本书
        /**
         * @Desc 测试代码添加几本书
         */
        Book[] bookarr = new Book[books.getCapacity()];
        bookarr[0] = new Book("三国演义", "罗贯中", 120);
        bookarr[1] = new Book("水浒传", "施耐庵", 200);
        bookarr[2] = new Book("西游记", "吴承恩", 150);
        books.setList(bookarr);
        books.setUsed_size(3);
        User user = choice == 0 ? new NormalUser(name) : new AdminUser(name);
        while(true){
            user.menu();    // polymorphic
            choice = scanner.nextInt();
            user.doOp(choice, books);
        }

    }
}
